package com.atguigu.yygh.rabbitmq.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author:hx
 * @DateTime:2022/11/17 14:00
 * @Description:
 */
@Service
public class RabbitMQService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * @Description 发送消息
     * @param exchange: 交换机
     * @param routingKey: 路由键
     * @param message:  消息
     * @return: java.lang.Boolean
     */
    public Boolean sendMessage(String exchange,String routingKey,Object message){
        rabbitTemplate.convertAndSend(exchange,routingKey,message);
        return true;
    }
}
